package com.yonyougov.cruxtestcase.testcase.context;

import com.yonyougov.cruxtestcase.basecase.BaseCase;
import com.yonyougov.cruxtestcase.dto.BaseResponseDto;
import com.yonyougov.cruxtestcase.dto.BaseTestReqDto;
import com.yonyougov.cruxtestcase.testcase.context.dto.ContextCaseReqDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 上下文测试用例
 */
@RestController
@RequestMapping("/api/contextcase/one")
public class ContextCaseOneController implements BaseCase {
    private final ContextCaseService contextCaseService;

    public ContextCaseOneController(ContextCaseService contextCaseService) {
        this.contextCaseService = contextCaseService;
    }

    @Override
    public String getName() {
        return "用户登陆之后，取上次登陆，用户的上下文信息";
    }

    @Override
    public String getRemark() {
        return "在江西省下用9个9用户新建用户1，9个9 退出；用户1登陆，上下文的用户任职组织默认是江西省";
    }

    @Override
    public BaseResponseDto testcase(BaseTestReqDto baseDto) {
        return null;
    }

    @PostMapping("/testcase")
    public BaseResponseDto testcaseOne(@RequestBody @Valid ContextCaseReqDto baseDto) throws Exception {
        return contextCaseService.caseOne(baseDto);
    }
}
